package TUILayer;
import java.util.Scanner;
import ControlLayer.*;
import ModelLayer.*;
/**
 * User interface to the DVD controller
 * @author(kbh)
 * @version(2005.03.31)
 * (FEN): 2006.02.24: Comments translated into English
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 * (KBH): 2008.10.24: dvdmenu changed to If                   
 */

public class DvdUI
{
    private DVDCtr dvdCtr;
    
    
    public DvdUI()
    {dvdCtr=new DVDCtr();
    }
    
    public void start()
    {
        
        dvdMenu();
    }
    
    public void dvdMenu()
    {   
        boolean exit = false;
        while(!exit)
        {
           
            int choice =   writeDVDMenu();
            if (choice == 1)
            {
                findDVD();
            }
            else{if(choice == 2){
                   createDVD();
                }
                else{
                    if(choice == 3){
                        createCopy();
                    }
                    else{
                        if(choice == 4){
                             deleteDVD();
                        }
                        else{
                            if(choice == 5){
                                listAllDvds();
                            }
                            else{
                                exit = true;System.out.println("\f");
                            }//end else
                        }//end else
                    }//end else
                }//end else
            }//end else
            
        }//end while
    }
    private int writeDVDMenu()
    {
           // creates an object keyboard to read data from the keyboard
            Scanner keyboard = new Scanner(System.in);
            System.out.println(" *** DVD Menu ***");
            System.out.println(" (1) Show DVD information");
            System.out.println(" (2) Create DVD description");
            System.out.println(" (3) Create DVD specimen");
            System.out.println(" (4) Delete DVD");
            System.out.println(" (5) Show current DVD list");
            System.out.println(" (6) Return");
            System.out.print("\n Make your choice: ");
            
            int choice = keyboard.nextInt();
            return choice;
    }
    private int inputDVDNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD number: ");
        int no = keyboard.nextInt();
        return no;
    }
    private String inputTitle()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type DVD title: " );
        String title = keyboard.nextLine();
        return title;
    }
    private int inputCopyNo()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy number: ");
        int no = keyboard.nextInt();
        return no;
    }
     private String inputArtist()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the artist: ");
        String artist = keyboard.nextLine();
        return artist;
    }
    
    private String inputPublicationDate()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy number: ");
        String publicationDate = keyboard.nextLine();
        return publicationDate;
    }
    private String inputCopyPurchaseDate()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy purchase date: ");
        String purchaseDate = keyboard.nextLine();
        return purchaseDate;
    }
    private String inputCopyPurchasePrice()
    {
        // creates an object keyboard to read data from the keyboard
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Type the copy purchase price: ");
        String purchasePrice= keyboard.nextLine();
        return purchasePrice;
    }
  
    private DVD findDVD()
    {     
        int no = inputDVDNo();
        //is to be changed when the DVD controller is completed
        return dvdCtr.findDVD(no);
    }
    private void createDVD()
    {int id=inputDVDNo();
     String title=inputTitle();
     String artist=inputArtist();
     String publicationDate=inputPublicationDate();
     dvdCtr.createDVD(id,title,artist,publicationDate);
    }
    private void createCopy()
    {int serialNumber=inputCopyNo();
     int no=inputDVDNo();
     String purchaseDate=inputCopyPurchaseDate();
     String purchasePrice=inputCopyPurchasePrice();
     dvdCtr.createCopy(no,serialNumber,purchaseDate,purchasePrice);
    }
    
    private void deleteDVD()
    {int no=inputDVDNo();
     dvdCtr.deleteDVD(no);
    }
    private void listAllDvds()
    {dvdCtr.listAllDvds();
    }
 
}